﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;
namespace DAL
{
	public class DANHSACHCONGVIECDAO:DALBase
	{
		public DANHSACHCONGVIECDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPDANHSACHCONGVIEC"; }
			set { _SpName = value; }
		}
		public DataTable GetListCV()
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new DANHSACHCONGVIEC(), null), ConvertClassToArray.GetValues(new DANHSACHCONGVIEC(), 0));
				return dt;
			}
			catch { return null; }
		}
		public List<DANHSACHCONGVIEC> GetListCVS()
		{
			dt = new DataTable();
			List<DANHSACHCONGVIEC> ds = new List<DANHSACHCONGVIEC>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new DANHSACHCONGVIEC(), null), ConvertClassToArray.GetValues(new DANHSACHCONGVIEC(), 0));
				ds = (List<DANHSACHCONGVIEC>)ConvertDatatableToList.ConvertTo<DANHSACHCONGVIEC>(dt);
				return ds;
			}
			catch { return null; }
		}
		public List<DANHSACHCONGVIEC> getdanhsachcongviec(DANHSACHCONGVIEC dv)
		{
			dt = new DataTable();
			List<DANHSACHCONGVIEC> ds = new List<DANHSACHCONGVIEC>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dv, null), ConvertClassToArray.GetValues(dv, 5));
				ds = (List<DANHSACHCONGVIEC>)ConvertDatatableToList.ConvertTo<DANHSACHCONGVIEC>(dt);
			}
			catch { return null; }
			return ds;
		}
		public List<DANHSACHCONGVIEC> GETDSCV(DANHSACHCONGVIEC dv)
		{
			dt = new DataTable();
			List<DANHSACHCONGVIEC> ds = new List<DANHSACHCONGVIEC>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dv, null), ConvertClassToArray.GetValues(dv, 8));
				ds = (List<DANHSACHCONGVIEC>)ConvertDatatableToList.ConvertTo<DANHSACHCONGVIEC>(dt);
			}
			catch { return null; }
			return ds;
		}
		public String CreatenewId()
		{
			try
			{
				return "CV" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new DANHSACHCONGVIEC(), null), ConvertClassToArray.GetValues(new DANHSACHCONGVIEC(), 1));

			}
			catch { return null; }
		}
		public bool INSERT(DANHSACHCONGVIEC cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

			}
			catch { return false; }
		}
		public bool UPDATE(DANHSACHCONGVIEC cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

			}
			catch { return false; }
		}
		public bool DELETE(DANHSACHCONGVIEC cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

			}
			catch { return false; }
		}
		public DataTable GetListTHEO(DANHSACHCONGVIEC ds)
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(ds, null), ConvertClassToArray.GetValues(ds, 5));
				return dt;
			}
			catch { return null; }
		}
		public DANHSACHCONGVIEC GETOBJECTDS(DANHSACHCONGVIEC dsv)
		{
			dt = new DataTable();
			DANHSACHCONGVIEC ds = new DANHSACHCONGVIEC();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dsv, null), ConvertClassToArray.GetValues(dsv, 6));
				ds = (DANHSACHCONGVIEC)ConvertDatatableToList.ConvertToObject<DANHSACHCONGVIEC>(dt);
			}
			catch { return null; }
			return ds;
		}
		public DataTable GETOBJECTDSNEWS(DANHSACHCONGVIEC dsv)
		{

			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dsv, null), ConvertClassToArray.GetValues(dsv, 7));
			}
			catch { return null; }
			return dt;
		}
		public DataTable GETDANHSACHCONGVIECTHANHTOAN(DANHSACHCONGVIEC dsv)
		{

			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dsv, null), ConvertClassToArray.GetValues(dsv, 10));
			}
			catch { return null; }
			return dt;
		}
		public DataTable GETDSCONGVIECBENHNHAN(DANHSACHCONGVIEC dsv)
		{

			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dsv, null), ConvertClassToArray.GetValues(dsv, 11));
			}
			catch { return null; }
			return dt;
		}
		public DataTable GETLISTCTKHAMBENH(DANHSACHCONGVIEC dsv)
		{

			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dsv, null), ConvertClassToArray.GetValues(dsv, 9));
			}
			catch { return null; }
			return dt;
		}
	}
}
